﻿using System;
using System.Collections.Generic;
using System.Text;
using PreguntaAlExperto.TransporterObjectsFramework;
using PreguntaAlExperto.RulesLayer.Entities;
using PreguntaAlExperto.ObjectMapper;
using PreguntaAlExperto.ObjectMapper.DTO;
using PreguntaAlExperto;

namespace PreguntaAlExperto.RulesLayer.Services
{
    public class AskExpertService
    {
        public BaseList<AskNode> getRootNodes()
        {
            AskExpertDTO _DTO = new AskExpertDTO();
            return ((BaseList<AskNode>)_DTO.Select("SQL_SELECT_ROOT_ASK_NODE", null));
        }

        public void CreateNewNode(AskNode _node)
        {
            AskExpertDTO _DTO = new AskExpertDTO();
            SearchCriteria _searchCriteria = new SearchCriteria();
            _searchCriteria.addParameter("@Publisher_ID", _node.PublisherOwner.ID_Publisher);
            _searchCriteria.addParameter("@Topic", _node.Topic);
            _searchCriteria.addParameter("@Comment_Body", _node.Comment_Body);
            _searchCriteria.addParameter("@Comment_Date", _node.Comment_Date);
            _searchCriteria.addParameter("@RecursiveAsk_ID", _node.ParentNode);

            _DTO.Update("SQL_INSERT_ASK_NODE", _searchCriteria);
        }
    }
}
